//防抖函数和节流函数的结合版


function debounce(fn,delay){
    let timer
    let starttime = 0
    return function(...args){
        if(timer){
            clearTimeout(timer)
        }
        let endtime = new Date().getTime()
        if((endtime-starttime)>delay){
            this.apply(fn,args)
        }else{
            timer = setTimeout(function(){
                this.apply(fn,args)
            },delay)
        }
        
    }
}